

package com.thxrinfo.stop.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.log.annotation.SysLog;
import com.thxrinfo.stop.api.entity.SpecialPassType;
import com.thxrinfo.stop.service.SpecialPassTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


/**
 * 特别放行表
 *
 * @author silencezheng
 * @date 2023-01-30 17:11:13
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/specialpasstype" )
@Tag(name = "特别放行表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SpecialPassTypeController {

    private final  SpecialPassTypeService specialPassTypeService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param specialPassType 特别放行表
     * @return
     */
    @Operation(summary = "分页查询", description = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('stop_specialpasstype_get')" )
    public R getSpecialPassTypePage(Page page, SpecialPassType specialPassType) {
        return R.ok(specialPassTypeService.page(page, Wrappers.query(specialPassType)));
    }


    /**
     * 通过id查询特别放行表
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('stop_specialpasstype_get')" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(specialPassTypeService.getById(id));
    }

    /**
     * 新增特别放行表
     * @param specialPassType 特别放行表
     * @return R
     */
    @Operation(summary = "新增特别放行表", description = "新增特别放行表")
    @SysLog("新增特别放行表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('stop_specialpasstype_add')" )
    public R save(@RequestBody SpecialPassType specialPassType) {
        return R.ok(specialPassTypeService.save(specialPassType));
    }

    /**
     * 修改特别放行表
     * @param specialPassType 特别放行表
     * @return R
     */
    @Operation(summary = "修改特别放行表", description = "修改特别放行表")
    @SysLog("修改特别放行表" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('stop_specialpasstype_edit')" )
    public R updateById(@RequestBody SpecialPassType specialPassType) {
        return R.ok(specialPassTypeService.updateById(specialPassType));
    }

    /**
     * 通过id删除特别放行表
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id删除特别放行表", description = "通过id删除特别放行表")
    @SysLog("通过id删除特别放行表" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('stop_specialpasstype_del')" )
    public R removeById(@PathVariable Long id) {
        return R.ok(specialPassTypeService.removeById(id));
    }

}
